<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui" 
	template="/template/template.xhtml">
	
  <f:metadata>  
  	<f:event type="preRenderView" listener="#{authorBean.refreshAuthors}" />
  </f:metadata>
  
  <ui:define name="center">
  	<h1 class="title ui-widget-header ui-corner-all">${msg['admin.author.title']}</h1>
  	<h:messages id="success" layout="table"/>
  	<h:form id="editForm">
  		<p:commandButton value="#{msg['admin.list.addAuthor']}" action="#{authorBean.addAction}"/>	<br/>
 		<p:dataTable var="author" value="#{authorBean.authors}">
  			<p:column>
  				<f:facet name="header">
  					<h:outputText value="#{msg['admin.list.header.nom']}" />
  				</f:facet>
  				<h:outputText value="#{author.firstName}" />
  			</p:column>
  			<p:column>
  				<f:facet name="header">
  					<h:outputText value="#{msg['admin.list.header.prenom']}" />
  				</f:facet>
  				<h:outputText value="#{author.lastName}" />
  			</p:column>
			<p:column>
  				<f:facet name="header">
  					<h:outputText value="#{msg['admin.list.header.action']}" />
  				</f:facet>
  				<h:commandLink value="#{msg['admin.list.header.action.modify']} " action="author">
  					<f:setPropertyActionListener target="#{authorBean.selectedAuthor}" value="#{author}" />
  				</h:commandLink>
  				<h:commandLink value="#{msg['admin.list.header.action.delete']}" action="#{authorBean.delete}">
  					<f:setPropertyActionListener target="#{authorBean.selectedAuthor}" value="#{author}" />
  				</h:commandLink>
  			</p:column>
  		</p:dataTable>
  	</h:form>
  </ui:define>
</ui:composition>